package com.mtiiot.fstcpclient;

import com.mtiiot.fscore.bean.MetadataInfo;
import com.mtiiot.fscore.bean.MqInfo;
import com.mtiiot.fscore.inter1.KafkaMqService1;
import com.mtiiot.fscore.inter1.RedisMqService1;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by Administrator on 2016/8/18.
 */
public class TestMq {

    public static KafkaMqService1 kafkaMqService1;
    public static RedisMqService1 redisMqService1;

    public static void testKafka(){
        String[] topics = {"N_YQ_TES_RPFB","N_YQ_QCM_RSZZ","N_BX_STA_HSZZ","N_YQ_TRA_RSZZ"};
        int i = 1;
        for (String topic : topics){
            for (int j = 0; j < 1; j++){
                MetadataInfo metadataInfo = new MetadataInfo();
                metadataInfo.setAccessKey("88888888");
                metadataInfo.setSysId("54e08d066a894a96be9f75854a72e5ca");
                metadataInfo.setL1Name("kafkaTestL1");
                metadataInfo.setL2Name("kafkaTestL2");
                metadataInfo.setL3Name("kafkaTestL3");
                metadataInfo.setHost("kafka192.168.2.168");
                MqInfo mqInfo = new MqInfo();
                mqInfo.setTopic(topic);
                mqInfo.setKey(""+i);
                mqInfo.setValue(topic+"_"+i);
                //kafkaMqService1.produceMessage(metadataInfo,mqInfo);
                redisMqService1.produceMessage(metadataInfo,mqInfo);
                i++;
            }
        }
    }

    public static void main(String[] args) {
        String path = "D:\\ideaworkspace\\mtiiot\\FSTcpClient\\src\\main\\resources\\applicationContext.xml";
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("file:"+path);
        kafkaMqService1 = context.getBean("kafkaMq",KafkaMqService1.class);
        redisMqService1 = context.getBean("redisMq",RedisMqService1.class);

        testKafka();

        System.out.println("sssssssss");

    }
}
